home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5618 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  1.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 6c 61 6e 67 2e 63 2b | 2b 0a 50 61 74 68 3a 20 |.lang.c+|+.Path: |
|00000020| 6e 65 77 73 2e 6e 65 72 | 2e 62 62 6e 70 6c 61 6e |news.ner|.bbnplan|
|00000030| 65 74 2e 6e 65 74 21 61 | 72 63 6f 21 75 73 65 6e |et.net!a|rco!usen|
|00000040| 65 74 0a 46 72 6f 6d 3a | 20 42 72 69 61 6e 20 4c |et.From:| Brian L|
|00000050| 65 61 63 68 20 3c 6c 61 | 73 62 66 6c 3e 0a 53 75 |each <la|sbfl>.Su|
|00000060| 62 6a 65 63 74 3a 20 52 | 65 3a 20 54 72 6f 75 62 |bject: R|e: Troub|
|00000070| 6c 65 20 77 2f 20 72 61 | 6e 64 6f 6d 20 6e 75 6d |le w/ ra|ndom num|
|00000080| 62 65 72 73 2e 2e 2e 70 | 6c 65 61 73 65 20 68 65 |bers...p|lease he|
|00000090| 6c 70 0a 58 2d 4e 6e 74 | 70 2d 50 6f 73 74 69 6e |lp.X-Nnt|p-Postin|
|000000a0| 67 2d 48 6f 73 74 3a 20 | 31 33 36 2e 32 32 36 2e |g-Host: |136.226.|
|000000b0| 31 31 36 2e 31 0a 43 6f | 6e 74 65 6e 74 2d 54 79 |116.1.Co|ntent-Ty|
|000000c0| 70 65 3a 20 74 65 78 74 | 2f 70 6c 61 69 6e 3b 20 |pe: text|/plain; |
|000000d0| 63 68 61 72 73 65 74 3d | 75 73 2d 61 73 63 69 69 |charset=|us-ascii|
|000000e0| 0a 4d 65 73 73 61 67 65 | 2d 49 44 3a 20 3c 44 4d |.Message|-ID: <DM|
|000000f0| 42 49 48 71 2e 4c 33 75 | 40 6e 65 77 73 2e 61 72 |BIHq.L3u|@news.ar|
|00000100| 63 6f 2e 63 6f 6d 3e 0a | 54 6f 3a 20 63 6f 74 74 |co.com>.|To: cott|
|00000110| 65 72 40 77 77 77 2e 63 | 6e 73 2e 75 6b 79 2e 65 |er@www.c|ns.uky.e|
|00000120| 64 75 0a 53 65 6e 64 65 | 72 3a 20 75 73 65 6e 65 |du.Sende|r: usene|
|00000130| 74 40 6e 65 77 73 2e 61 | 72 63 6f 2e 63 6f 6d 0a |t@news.a|rco.com.|
|00000140| 43 6f 6e 74 65 6e 74 2d | 54 72 61 6e 73 66 65 72 |Content-|Transfer|
|00000150| 2d 45 6e 63 6f 64 69 6e | 67 3a 20 37 62 69 74 0a |-Encodin|g: 7bit.|
|00000160| 4f 72 67 61 6e 69 7a 61 | 74 69 6f 6e 3a 20 41 52 |Organiza|tion: AR|
|00000170| 43 4f 20 4f 69 6c 20 25 | 20 47 61 73 20 43 6f 6d |CO Oil %| Gas Com|
|00000180| 70 61 6e 79 0a 52 65 66 | 65 72 65 6e 63 65 73 3a |pany.Ref|erences:|
|00000190| 20 3c 34 66 30 67 35 75 | 24 38 37 39 40 6e 73 2e | <4f0g5u|$879@ns.|
|000001a0| 63 61 6d 70 75 73 2e 6d | 63 69 2e 6e 65 74 3e 0a |campus.m|ci.net>.|
|000001b0| 4d 69 6d 65 2d 56 65 72 | 73 69 6f 6e 3a 20 31 2e |Mime-Ver|sion: 1.|
|000001c0| 30 0a 44 61 74 65 3a 20 | 4d 6f 6e 2c 20 35 20 46 |0.Date: |Mon, 5 F|
|000001d0| 65 62 20 31 39 39 36 20 | 31 39 3a 33 37 3a 30 31 |eb 1996 |19:37:01|
|000001e0| 20 47 4d 54 0a 58 2d 4d | 61 69 6c 65 72 3a 20 4d | GMT.X-M|ailer: M|
|000001f0| 6f 7a 69 6c 6c 61 20 31 | 2e 31 32 20 28 58 31 31 |ozilla 1|.12 (X11|
|00000200| 3b 20 49 3b 20 48 50 2d | 55 58 20 41 2e 30 39 2e |; I; HP-|UX A.09.|
|00000210| 30 35 20 39 30 30 30 2f | 37 35 35 29 0a 58 2d 55 |05 9000/|755).X-U|
|00000220| 72 6c 3a 20 6e 65 77 73 | 3a 34 66 30 67 35 75 24 |rl: news|:4f0g5u$|
|00000230| 38 37 39 40 6e 73 2e 63 | 61 6d 70 75 73 2e 6d 63 |879@ns.c|ampus.mc|
|00000240| 69 2e 6e 65 74 0a 0a 44 | 61 6e 69 65 6c 20 43 6f |i.net..D|aniel Co|
|00000250| 74 74 65 72 20 3c 63 6f | 74 74 65 72 40 77 77 77 |tter <co|tter@www|
|00000260| 2e 63 6e 73 2e 75 6b 79 | 2e 65 64 75 3e 20 77 72 |.cns.uky|.edu> wr|
|00000270| 6f 74 65 3a 0a 3e 49 27 | 6d 20 74 72 79 69 6e 67 |ote:.>I'|m trying|
|00000280| 20 74 6f 20 77 72 69 74 | 65 20 61 20 70 72 6f 67 | to writ|e a prog|
|00000290| 72 61 6d 20 74 68 61 74 | 20 77 69 6c 6c 20 67 65 |ram that| will ge|
|000002a0| 6e 65 72 61 74 65 20 61 | 20 73 65 74 20 6f 66 0a |nerate a| set of.|
|000002b0| 3e 72 61 6e 64 6f 6d 20 | 6e 75 6d 62 65 72 73 20 |>random |numbers |
|000002c0| 62 65 74 77 65 65 6e 20 | 33 20 61 6e 64 20 31 38 |between |3 and 18|
|000002d0| 2e 20 49 20 68 61 76 65 | 20 73 65 76 65 72 61 6c |. I have| several|
|000002e0| 20 70 72 6f 62 6c 65 6d | 73 20 77 69 74 68 0a 3e | problem|s with.>|
|000002f0| 74 68 69 73 20 70 72 6f | 67 72 61 6d 2e 0a 3e 31 |this pro|gram..>1|
|00000300| 2e 20 43 2b 2b 20 61 6c | 77 61 79 73 20 67 65 6e |. C++ al|ways gen|
|00000310| 65 72 61 74 65 73 20 73 | 61 6d 65 20 6e 75 6d 62 |erates s|ame numb|
|00000320| 65 72 28 33 34 36 29 0a | 3e 32 2e 20 49 20 64 6f |er(346).|>2. I do|
|00000330| 6e 27 74 20 6b 6e 6f 77 | 20 68 6f 77 20 74 6f 20 |n't know| how to |
|00000340| 67 69 76 65 20 61 20 72 | 61 6e 67 65 2e 20 49 27 |give a r|ange. I'|
|00000350| 76 65 20 74 72 69 65 64 | 20 33 2d 31 38 2c 20 62 |ve tried| 3-18, b|
|00000360| 75 74 0a 3e 20 20 20 69 | 74 20 74 68 69 6e 6b 73 |ut.> i|t thinks|
|00000370| 20 49 20 6d 65 61 6e 20 | 74 6f 20 73 75 62 74 72 | I mean |to subtr|
|00000380| 61 63 74 28 33 2d 31 38 | 3d 31 35 29 0a 3e 33 2e |act(3-18|=15).>3.|
|00000390| 20 57 68 65 6e 20 69 74 | 20 64 6f 65 73 20 77 6f | When it| does wo|
|000003a0| 72 6b 2c 20 69 74 27 73 | 20 61 6c 77 61 79 73 20 |rk, it's| always |
|000003b0| 74 68 65 20 73 61 6d 65 | 20 6e 75 6d 62 65 72 0a |the same| number.|
|000003c0| 3e 0a 3e 50 6c 65 61 73 | 65 20 68 65 6c 70 2c 0a |>.>Pleas|e help,.|
|000003d0| 3e 43 6f 74 74 65 72 0a | 3e 0a 3e 22 4f 75 74 20 |>Cotter.|>.>"Out |
|000003e0| 6f 66 20 74 68 65 20 62 | 6c 61 63 6b 20 61 6e 64 |of the b|lack and|
|000003f0| 20 69 6e 74 6f 20 74 68 | 65 20 62 6c 75 65 22 2d | into th|e blue"-|
|00000400| 4e 65 69 6c 20 59 6f 75 | 6e 67 0a 3e 0a 0a 49 66 |Neil You|ng.>..If|
|00000410| 20 79 6f 75 20 61 72 65 | 20 75 73 69 6e 67 20 74 | you are| using t|
|00000420| 68 65 20 74 68 65 20 72 | 61 6e 64 28 29 20 66 75 |he the r|and() fu|
|00000430| 6e 63 74 69 6f 6e 2c 20 | 64 6f 6e 27 74 20 66 6f |nction, |don't fo|
|00000440| 72 67 65 74 20 74 6f 20 | 73 65 65 64 20 69 74 20 |rget to |seed it |
|00000450| 77 69 74 68 0a 73 72 61 | 6e 64 28 29 2e 20 42 75 |with.sra|nd(). Bu|
|00000460| 74 20 64 6f 6e 27 74 20 | 64 6f 20 74 68 61 74 20 |t don't |do that |
|00000470| 75 6e 74 69 6c 20 61 66 | 74 65 72 20 79 6f 75 72 |until af|ter your|
|00000480| 20 68 61 76 65 20 66 69 | 67 75 72 65 64 20 6f 75 | have fi|gured ou|
|00000490| 74 20 74 68 65 20 72 65 | 73 74 20 6f 66 0a 79 6f |t the re|st of.yo|
|000004a0| 75 72 20 70 72 6f 67 72 | 61 6d 2e 20 54 68 65 20 |ur progr|am. The |
|000004b0| 72 65 70 65 61 74 69 6e | 67 20 73 65 71 75 65 6e |repeatin|g sequen|
|000004c0| 63 65 20 6d 61 6b 65 73 | 20 64 65 62 75 67 67 69 |ce makes| debuggi|
|000004d0| 6e 67 20 65 61 73 69 65 | 72 2e 0a 0a 42 65 79 6f |ng easie|r...Beyo|
|000004e0| 6e 64 20 74 68 61 74 2c | 20 79 6f 75 20 68 61 76 |nd that,| you hav|
|000004f0| 65 20 61 20 6e 6f 72 6d | 61 6c 69 7a 61 74 69 6f |e a norm|alizatio|
|00000500| 6e 20 70 72 6f 62 6c 65 | 6d 2e 20 46 6f 72 20 61 |n proble|m. For a|
|00000510| 20 67 6f 6f 64 20 61 6e | 73 77 65 72 2c 20 63 6f | good an|swer, co|
|00000520| 6e 73 75 6c 74 0a 6f 6e | 65 20 6f 66 20 74 68 65 |nsult.on|e of the|
|00000530| 20 6d 61 6e 79 20 61 6c | 67 6f 72 69 74 68 6d 20 | many al|gorithm |
|00000540| 62 6f 6f 6b 73 2e 20 41 | 20 71 75 69 63 6b 20 61 |books. A| quick a|
|00000550| 6e 73 77 65 72 20 69 73 | 20 74 6f 20 75 73 65 20 |nswer is| to use |
|00000560| 6d 6f 64 75 6c 75 73 20 | 61 72 69 74 68 6d 65 74 |modulus |arithmet|
|00000570| 69 63 3a 0a 0a 20 20 69 | 6e 74 20 72 61 6e 67 65 |ic:.. i|nt range|
|00000580| 20 3d 20 28 31 38 20 2d | 20 33 29 20 2b 20 31 3b | = (18 -| 3) + 1;|
|00000590| 0a 20 20 69 6e 74 20 76 | 20 3d 20 28 72 61 6e 64 |. int v| = (rand|
|000005a0| 28 29 25 72 61 6e 67 65 | 29 20 2b 20 33 3b 0a 20 |()%range|) + 3;. |
|000005b0| 0a 20 0a 49 20 68 6f 70 | 65 20 49 27 6d 20 6e 6f |. .I hop|e I'm no|
|000005c0| 74 20 64 6f 69 6e 67 20 | 79 6f 75 72 20 6c 61 62 |t doing |your lab|
|000005d0| 20 66 6f 72 20 79 6f 75 | 2e 2e 2e 2e 0a 0a 2d 42 | for you|......-B|
|000005e0| 72 69 61 6e 20 3a 2d 29 | 0a 0a |rian :-)|.. |
+--------+-------------------------+-------------------------+--------+--------+